package cn.web.tunnelrobot.controller;

import cn.web.tunnelrobot.dto.ThresholdDTO;
import cn.web.tunnelrobot.service.ThresholdService;
import com.github.xiaoymin.knife4j.annotations.ApiSort;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;

@RestController
@RequestMapping("/threshold")
@Api(tags = "警告统计")
@ApiSort(value = 8)
public class ThresholdController {
    @Autowired
    private ThresholdService thresholdService;

    /**
     * 阀值批量修改
     * threshold 表
     * @param thresholdDTO
     * @return
     */
    @PostMapping("/updateBatchThreshold")
    @ResponseBody
    @ApiOperation(value = "阈值设置",notes = "阀值批量修改")
    public HashMap<String,Object> updateBatchThreshold(@RequestBody ThresholdDTO thresholdDTO){
        return thresholdService.updateBatchThreshold(thresholdDTO.thresholdlist);
    }


    /**
     * 查询阈值列表
     * threshold 表
     * @param thWarningSign
     * @return
     */
    @GetMapping("/getThresholdList")
    @ResponseBody
    @ApiOperation(value = "thWarningSign",notes = "查询阈值列表")
    public HashMap<String,Object> getThresholdList(Integer thWarningSign){
        return thresholdService.getThresholdList(thWarningSign);
    }

    /**
     * 警告统计
     * warningrecord 表
     * @return
     */
    @GetMapping("/getWarningStatistics" )
    @ResponseBody
    @ApiOperation(value ="无",notes = "警告统计")
    public HashMap<String,Object> getWarningStatistics(){
        return thresholdService.getWarningStatistics();
    }

    /**
     * 近七日警告预警记录
     * warningrecord 表
     * @return
     */
    @GetMapping("/getEarlyWarning" )
    @ResponseBody
    @ApiOperation(value ="无",notes = "近七日警告预警记录")
    public HashMap<String,Object> getEarlyWarning(){
        return thresholdService.getEarlyWarning();
    }
}
